// import ChartConst from '../../constants/chartConst';
import BarChart from '../chartModel/barChart.js';
import LineChart from '../chartModel/lineChart.js';
// import PieChart from '../chartModel/pieChart.js';


class ChartModelUtil {
  constructor() {
    
  }
  // static ChartList = [
  //   ChartConst.column,
  //   ChartConst.bar,
  //   ChartConst.scatter,
  //   ChartConst.bubble,
  //   ChartConst.line,
  //   ChartConst.area,
  //   ChartConst.columnLine,
  //   ChartConst.pie,
  //   ChartConst.circle,
  //   ChartConst.rose,
  //   ChartConst.radar,
  //   ChartConst.map,
  //   ChartConst.scatter
  // ];
  // 静态方法
  static isAxisChart(ctype) {
    return publicJudgeCtype('isAxisChart', ctype);
  }
  static isBarTypeChart(ctype) { //条形类图
    return publicJudgeCtype('isBarTypeChart', ctype);
  }
  static isColumnTypeChart(ctype) { //纵向柱状图
    return publicJudgeCtype('isColumnTypeChart', ctype);
  }
  static isStackPolarBarChart(ctype) {
    return publicJudgeCtype('isStackPolarBarChart', ctype);
  }

  static isLineOrAreaTypeChart(ctype) {
    return publicJudgeCtype('isLineOrAreaTypeChart', ctype);
  }
  static isAreaTypeChart(ctype) {
    return publicJudgeCtype('isAreaTypeChart', ctype);
  }
  static isScatterOrBubbleTypeChart(ctype) {
    return publicJudgeCtype('isScatterOrBubbleTypeChart', ctype);
  }

  static isPieTypeChart(ctype) {
    return publicJudgeCtype('isPieTypeChart', ctype);
  }
  static isMultipleCircleChart(ctype) {
    return publicJudgeCtype('isMultipleCircleChart', ctype);
  }

  static getChartByChartType(chartType) {
    let chart = null;
    if (ChartModelUtil.isBarTypeChart(chartType) || ChartModelUtil.isColumnTypeChart(chartType)) {
      chart = new BarChart();
      return chart;
    }
    if (ChartModelUtil.isLineOrAreaTypeChart(chartType)) {
      chart = new LineChart();
      return chart;
    }
    // if (ChartModelUtil.isPieTypeChart(chartType)) {
    //   chart = new PieChart();
    //   return chart;
    // }
    // if (ChartModelUtil.isMultipleCircleChart(chartType)) {
    //   chart = new MultipleCircleChart();
    //   return chart;
    // }
    // if (ChartModelUtil.isScatterOrBubbleTypeChart(chartType)) {
    //   chart = new ScatterChart();
    //   return chart;
    // }
    // if (chartType == ChartConst.radar) {
    //   chart = new RadarChart();
    //   return chart;
    // }
    // if (chartType == ChartConst.map) {
    //   chart = new MapChart();
    //   return chart;
    // }
    // if (chartType == ChartConst.stackPolarBar) {
    //   chart = new StackBarChartInPolar();
    //   return chart;
    // }
  }
  static getChartOption = (params) => {
    let option = null;
    const chart = ChartModelUtil.getChartByChartType(params.chartType);
    option = chart.getOption(params);
    return option;
  }
}
// 公共判断ctype的类型来区分应具有的属性
const publicJudgeCtype = (name, ctype) => {
  const ctypeObj = {
    isAxisChart: '$bar$,$bar-chart$,$zxdj$,$stacking-bar-chart$,$scatter$,$bubble$,$line$,$area$,$bar-line$',
    isBarTypeChart: '$bar$,$barLine$',
    isColumnTypeChart: '$column$,$columnLine$,$columnArea$',
    isStackPolarBarChart: '$stackPolarBar$',
    isLineOrAreaTypeChart: '$line$,$area$,$columnArea$',
    isAreaTypeChart:'$area$,$columnArea$',
    isScatterOrBubbleTypeChart: '$scatter$,$bubble$',
    isPieTypeChart: '$pie$,$circle$,$rose$',
    isMultipleCircleChart: '$multipleCircle$'
  };
  return ctypeObj[name].indexOf(`$${ctype}$`) > -1;
};
export default ChartModelUtil;
